package com.leadbank.security.hello.service;

import com.leadbank.security.hello.dao.CountryDAO;
import com.leadbank.security.hello.dao.EmployeeDao;
import com.leadbank.security.hello.model.Country;
import com.leadbank.security.hello.model.CountryExample;
import com.leadbank.security.hello.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class CountryServiceImpl implements CountryService {
	
	@Autowired
	private CountryDAO countryDAO;

	@Override
	public List<Country> getCountryList() {
		CountryExample countryExample = new CountryExample();
		List<String> countrynameList = new ArrayList<>();
		countrynameList.add("china");
		countrynameList.add("india");
		countryExample.or().andCountrynameIn(countrynameList);
		List<Country> countryList = countryDAO.selectByExample(countryExample);

		return countryList;
	}

	@Override
	public void deleteCountry(String countrycode) {
		CountryExample countryExample = new CountryExample();
		countryExample.or().andCountrycodeEqualTo(countrycode);
		countryDAO.deleteByExample(countryExample);
	}
}
